package com.fierce.cloud.core.web;


import com.fierce.cloud.core.web.responseDto.Response;
import com.fierce.cloud.exception.ResultStatusEnum;

/**
 * 响应结果生成工具
 */
public class ResultGenerator {

    public static Response genSuccessResult() {
        return new Response(200, "请求成功！", true);
    }

    public static <T> Response<T> genSuccessResult(String message,T data) {
        return new Response(200, message, true, data);
    }

    public static Response genSuccessResult(String message) {
        return new Response(200, message, true);
    }

    public static <T> Response<T> genSuccessResult(T data) {
        return new Response(200, "请求成功！", true, data);
    }

    public static Response genFailResult(int code, String message) {
        return new Response(code, message, false);
    }

    public static Response genSuccessResult(ResultStatusEnum success) {
        return new Response(success.getCode(), success.getMessage(), success.getResult());
    }

    public static Response genFailResult(String message) {
        return new Response(400, message, false);
    }

    public static Response genFailResult(ResultStatusEnum fail) {
        return new Response(fail.getCode(), fail.getMessage(), fail.getResult());
    }
}
